adding the foundation of extensions
authorØyvind Kolås <ok@src.gnome.org>
Sat, 27 Aug 2005 20:29:49 +0000 (20:29 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Sat, 27 Aug 2005 20:29:49 +0000 (20:29 +0000)
32 files changed:
ChangeLog
babl.pc.in
babl/Makefile.am
babl/babl-classes.c
babl/babl-classes.h
babl/babl-component.h
babl/babl-conversion.c
babl/babl-conversion.h
babl/babl-core.c [new file with mode: 0644]
babl/babl-core.h [new file with mode: 0644]
babl/babl-db.h
babl/babl-fish.h
babl/babl-format.h
babl/babl-ids.h
babl/babl-internal.c
babl/babl-internal.h
babl/babl-introspect.c
babl/babl-introspect.h
babl/babl-memory.c
babl/babl-model.h
babl/babl-pixel-format.h
babl/babl-sampling.h
babl/babl-sanity.c
babl/babl.c
babl/babl.h
babl/base/Makefile.am
babl/base/babl-base.c
babl/base/model-rgb.c
babl/base/type-double.c [deleted file]
docs/index-static.html.in
tests/Makefile.am
tests/introspect.c

index e289389a8fd76a72911145424c6b6c508b81e88d..2ed08137daed8dbe8df1aa5efe01cea838193f02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+2005-08-27  Øyvind Kolås  <pippin@gimp.org>
+
+       * Makefile.am:
+       * babl.pc.in: added -dl
+       * babl/babl-classes.c: Added BablExtension to string list of types.
+       * babl/babl-classes.h: Added BablExtension, some reordering in union.
+       * babl/babl-conversion.c:
+               (create_name), (babl_conversion_new): compute the name of the
+               conversion instead of explicitly having to provide it.
+       * babl/babl-core.c:
+               (convert_double_double), (copy_strip_1),
+               (babl_core_init): Moved double datatype and RGBA model from
+               base into core.
+       * babl/babl-core.h: new file
+       * babl/babl-db.h: improved logging, print current extender as well.
+       * babl/babl-ids.h: removed some non central ids.
+       * babl/babl-internal.h: new varargs based logger.
+       * babl/babl-introspect.c: (babl_introspect): use quiet "fake"
+       extender. Allow introspection of single objects.
+       * babl/babl-introspect.h: Allow introspection of single objects.
+       * babl/babl-memory.c: (babl_memory_sanity): use babl_log instead of
+       fprintf.
+       * babl/babl-sanity.c: (id_sanity): only complain about id==0 in
+       BablBase / BablCore.
+       * babl/babl.c: (babl_init), (babl_destroy): added core and extension
+       to build up/tear down lists.
+       * babl/babl.h: removed babl_introspect which doesn't belong here
+       anymore.
+       * babl/base/Makefile.am: Removed type-double.c
+       * babl/base/babl-base.c: (types), (models): removed
+       babl_base_type_double ()
+       * babl/base/model-rgb.c: (components), (models): removed RGBA model.
+       * babl/base/type-double.c: removed
+       
+       * docs/index-static.html.in:
+       * tests/Makefile.am: LDADD += -ldl 
+       * tests/introspect.c: (main): pass NULL as argument to
+       babl_introspect () to do full objectspace traversal.
+
+       * babl/babl-fish.h:
+       * babl/babl-model.h:
+       * babl/babl-pixel-format.h:
+       * babl/babl-sampling.h:
+       * babl/babl-conversion.h:
+       * babl/babl-component.h: cosmetic rearrangement of lines.
+
 2005-08-27  Øyvind Kolås  <pippin@gimp.org>
 
        * babl/babl-component.c: (babl_component_new):
index 8635189b5b8f9f9a9eb5c3fc8e84eabd9ed0a6d7..4b995f3b167e16cc4aca8e265de98630f566e184 100644 (file)
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: babl
 Description: Dynamic; any to any, pixel format conversion library
 Version: @VERSION@
-Libs: -L${libdir} -lbabl
-Cflags: -I${includedir}/babl
+Libs: -L${libdir} -lbabl -ldl
+Cflags: -I${includedir}/babl-0.0/babl
 
index 46efd3373be34186b486473c7de3b538e470271b..a8f24650a80c22bcb56da5576eebb0c9f5fcf569 100644 (file)
@@ -5,8 +5,10 @@ SUBDIRS = base
 c_sources =                            \
         babl.c                         \
        babl-classes.c                  \
+       babl-core.c                     \
        babl-component.c                \
        babl-conversion.c               \
+       babl-extension.c                \
        babl-fish.c                     \
        babl-image.c                    \
        babl-introspect.c               \
@@ -21,8 +23,10 @@ c_sources =                          \
 h_sources  =                           \
        babl-classes.h                  \
        babl-component.h                \
+       babl-core.h                     \
        babl-conversion.h               \
        babl-db.h                       \
+       babl-extension.h                \
        babl-ids.h                      \
        babl-instance.h                 \
        babl-internal.h                 \
@@ -44,8 +48,11 @@ library_include_HEADERS =            \
        babl-classes.h                  \
        babl-component.h                \
        babl-conversion.h               \
+       babl-extension.h                \
        babl-fish.h                     \
+       babl-ids.h                      \
        babl-image.h                    \
+       babl-instance.h                 \
        babl-model.h                    \
        babl-pixel-format.h             \
        babl-sampling.h                 \
@@ -64,4 +71,3 @@ libbabl_la_LDFLAGS= \
 
 EXTRA_DIST :=                  \
        .cvsignore
-
index 479ac68aed1dc6cdace06c9e3e4dbcaa5b0b1f4a..749d58f632bec4bce94e464c86d3eaa5c90a486a 100644 (file)
@@ -17,7 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "babl-classes.h"
+#include "babl-internal.h"
 
 static const char *class_names[] =
   {
@@ -38,6 +38,7 @@ static const char *class_names[] =
     "BablFish",
     "BablFishReference",
     "BablImage",
+    "BablExtenstion",
     "BablSky"
   };
 
@@ -53,3 +54,13 @@ babl_class_name (BablClassType klass)
  */
 int babl_hmpf_on_name_lookups = 0;
 
+void
+babl_internal_init (void)
+{
+}
+
+void
+babl_internal_destroy (void)
+{
+}
+
index 38119345fa7fa7c7f00542dfec49b50224610bb5..1ee34dbf2d5d08967f1ea08afb55ea037949bcdd 100644 (file)
@@ -75,13 +75,12 @@ typedef enum {
   BABL_FISH_REFERENCE,
   BABL_IMAGE,
 
+  BABL_EXTENSION,
+
   BABL_SKY
 } BablClassType;
 
-#define BABL_CLASS_TYPE_IS_VALID(klass_type) \
-    (  ((klass_type)>=BABL_INSTANCE ) && ((klass_type)<=BABL_SKY) ?1:0 )
 
-const char  *babl_class_name     (BablClassType klass);
 
 /* common header for any item inserted into database */
 typedef struct
@@ -89,9 +88,11 @@ typedef struct
   BablClassType  class_type;
   int            id;      /*< a numerical id, look at 'babl-ids.h' for the reserved
                               ones */
+  void          *creator;
   char          *name;    /*< the name this type exists under         */
 } BablInstance;
 
+
 typedef struct
 BablConversion {
   BablInstance           instance;
@@ -160,6 +161,7 @@ typedef struct
    * mantissa */
 } BablTypeFloat;
 
+
 typedef struct
 {
   BablInstance     instance;
@@ -226,7 +228,6 @@ typedef struct
   union Babl     *destination;
 } BablFish;
 
-
 /* BablFishReference on the double versions of conversions
  * that are required to exist for maximum sanity.
  *
@@ -244,6 +245,13 @@ typedef struct
   BablFish         fish;
 } BablFishReference;
 
+typedef struct
+{
+  BablInstance   instance;               /* path to .so / .dll is stored in instance name */
+  void          *dl_handle;
+  void         (*destroy) (void); 
+} BablExtension;
+
 typedef union
 {
   BablClassType     class_type;
@@ -254,18 +262,11 @@ typedef union
   BablModel         model;
   BablFormat        format;
   BablConversion    conversion;
+  BablImage         image;
   BablFish          fish;
   BablFishReference reference_fish;
-  BablImage         image;
+  BablExtension     extension;
 } Babl;
 
-
-#define BABL_IS_BABL(obj)                              \
-(NULL==(obj)?0:                                        \
- BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type)  \
-)
-
-#include "babl-instance.h"
-
 #endif
 
index dc7c26afa0d11103a631142e302ffa72f8ba776f..6ad5d8c107d0cf4a998ecb26249668c672180f5e 100644 (file)
@@ -21,6 +21,8 @@
 #define _BABL_COMPONENT_H
 
 #include "babl-classes.h"
-BABL_DEFINE_CLASS (babl_component)
+#include "babl-instance.h"
+
 
+BABL_DEFINE_CLASS (babl_component)
 #endif
index 278dfc751266b1e86ffbc17138c6061849199968..80a4a7470dfbb945a1080db0fc22be57f541552c 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "babl-internal.h"
 #include "babl-db.h"
+#include "babl-extension.h"
 #include "assert.h"
 #include <string.h>
 #include <stdarg.h>
@@ -123,6 +124,24 @@ conversion_new (const char        *name,
   return babl;
 }
 
+static char buf[512]="";
+static char *
+create_name (Babl *source, Babl *destination)
+{
+
+  if (babl_extender ())
+    {
+      snprintf (buf, 512-1, "%s::%s to %s", BABL(babl_extender())->instance.name, source->instance.name, destination->instance.name);
+      buf[511]='\0';
+    }
+  else
+    {
+      snprintf (buf, 512-1, "%s to %s", source->instance.name, destination->instance.name);
+      buf[511]='\0';
+    }
+  return buf;
+}
+
 Babl *
 babl_conversion_new (const char *name,
                      ...)
@@ -210,7 +229,7 @@ babl_conversion_new (const char *name,
   assert (source);
   assert (destination);
 
-  babl = conversion_new (name, id, source, destination, time_cost, loss, linear,
+  babl = conversion_new (create_name (source, destination), id, source, destination, time_cost, loss, linear,
                          planar, planar_bit);
 
   if (db_insert (babl) == babl)
index 286d6a2a0c85e8810b5aaccef71d4748db99a5c2..a3d1c6a42c80ca8cbbf8e20ead3f45790677d55f 100644 (file)
 #define BABL_CONVERSION_H
 
 #include "babl-classes.h"
-
-BABL_DEFINE_CLASS (babl_conversion)
+#include "babl-instance.h"
 
 void babl_conversion_process (BablConversion *conversion,
                               void           *source,
                               void           *destination,
                               long           n);
 
+BABL_DEFINE_CLASS (babl_conversion)
 #endif
diff --git a/babl/babl-core.c b/babl/babl-core.c
new file mode 100644 (file)
index 0000000..90cb7ec
--- /dev/null
@@ -0,0 +1,115 @@
+#include <string.h>
+#include "util.h"
+#include "babl.h"
+
+static void
+convert_double_double (void *src,
+                       void *dst,
+                       int   src_pitch,
+                       int   dst_pitch,
+                       int   n)
+{
+  if (src_pitch == 64 &&
+      dst_pitch == 64)
+    {
+      memcpy (dst, src, n/8);
+      return;
+    }
+  while (n--)
+    {
+      (*(double *) dst) = (*(double *) src);
+      dst += dst_pitch;
+      src += src_pitch;
+    }
+}
+
+
+static void
+copy_strip_1 (int    src_bands,
+              void **src,
+              int   *src_pitch,
+              int    dst_bands,
+              void **dst,
+              int   *dst_pitch,
+              int    n)
+{
+  BABL_PLANAR_SANITY
+  while (n--)
+    {
+      int i;
+
+      for (i=0;i<dst_bands;i++)
+        {
+          double foo;
+          if (i<src_bands)
+            foo = *(double *) src[i];
+          else
+            foo = 1.0;
+          *(double*)dst[i] = foo;
+        }
+
+      BABL_PLANAR_STEP
+    }
+}
+
+void
+babl_core_init (void)
+{
+  babl_type_new (
+    "double",
+    "id",          BABL_DOUBLE,
+    "bits",        64,
+    NULL);
+
+  babl_conversion_new (
+    "babl-base: double to double",
+    "source",      babl_type_id (BABL_DOUBLE),
+    "destination", babl_type_id (BABL_DOUBLE),
+    "linear", convert_double_double,
+    NULL
+  );
+
+  babl_component_new (
+    "R",
+    "id", BABL_RED,
+    "luma",
+    "chroma",
+    NULL);
+
+  babl_component_new (
+   "G",
+    "id",   BABL_GREEN,
+   "luma", 
+   "chroma",
+   NULL);
+  
+  babl_component_new (
+   "B",
+    "id",   BABL_BLUE,
+   "luma",
+   "chroma",
+   NULL);
+
+  babl_component_new (
+   "A",
+   "id",    BABL_ALPHA,
+   "alpha",
+   NULL);
+
+  babl_model_new (
+    "rgba",
+    "id", BABL_RGBA,
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+
+  babl_conversion_new (
+    "babl-base: rgba to rgba",
+    "source",      babl_model_id (BABL_RGBA),
+    "destination", babl_model_id (BABL_RGBA),
+    "planar",      copy_strip_1,
+    NULL
+  );
+}
diff --git a/babl/babl-core.h b/babl/babl-core.h
new file mode 100644 (file)
index 0000000..e75909c
--- /dev/null
@@ -0,0 +1,25 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef BABL_CORE_H
+#define BABL_CORE_H
+
+void babl_core_init (void);
+
+#endif
index 8dd08849245e7e185264ea769691b190a21a05f2..1b1c9377c889d0c55a8027f8553c48eed71e6859 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include "babl-instance.h"
+#include "babl-extension.h"
 
 #include <string.h>
 
@@ -101,7 +102,6 @@ db_destroy (void)
   db         = NULL;
 }
 
-
 DB_DEF Babl *
 db_insert (Babl *babl)
 {
@@ -117,14 +117,14 @@ db_insert (Babl *babl)
 
   if (collision)
     {
-      if (!strcmp (collision->instance.name, babl->instance.name))
-        babl_log ("conflicting name: existing(%i:'%s') - new(%i:'%s')",
-                collision->instance.id, collision->instance.name,
-                babl->instance.id, babl->instance.name);
+      if (!strcmp (collision->instance.name, babl->instance.name)    )
+        babl_log ("conflicting name:\n\t\tnew: '%s'\n\t\texisting '%s' from %s",
+                babl->instance.name, collision->instance.name,
+                BABL(collision->instance.creator)->instance.name);
       else if (collision->instance.id == babl->instance.id)
-        babl_log ("conflicting id: existing(%i:'%s') - new(%i:'%s')",
-                collision->instance.id, collision->instance.name,
-                babl->instance.id, babl->instance.name);
+        babl_log ("conflicting id:\n\t\tnew: '%s' (id=%i)\n\t\texisting '%s' from %s",
+                babl->instance.name, babl->instance.id, collision->instance.name,
+                BABL(collision->instance.creator)->instance.name);
       return collision;
     }
 
@@ -145,6 +145,7 @@ db_insert (Babl *babl)
       memset (db + db_size, 0, DB_INCREMENT_SIZE * sizeof (Babl*));
       db_size += DB_INCREMENT_SIZE;
     }
+  babl->instance.creator = babl_extender ();
   db[db_entries++]=babl;
   return babl;
 }
index 5bb25532cb5ec84ef52da6185bcb54d03a210865..0b15bb245621681c6ddc162874ac1d98c21d25ff 100644 (file)
@@ -21,8 +21,7 @@
 #define BABL_FISH_H
 
 #include "babl-classes.h"
-
-BABL_DEFINE_CLASS_NO_NEW_NO_ID(babl_fish)
+#include "babl-instance.h"
 
 /** create a new BablFish capable of translating between the pixel
  *  formats given in source and destination. (use babl_format (string))
@@ -44,4 +43,7 @@ int    babl_process           (Babl *babl_fish,
  */
 int    babl_fish_needs_image  (Babl *babl_fish);
 
+
+
+BABL_DEFINE_CLASS_NO_NEW_NO_ID(babl_fish)
 #endif
index 2a5f879db639a3dc4a5d63df3ba4852a35a69d97..ed3329cbf7c55ec6ebe43cf25ac3e02baf8ad99a 100644 (file)
@@ -21,6 +21,8 @@
 #define _BABL_FORMAT_H
 
 #include "babl-classes.h"
+#include "babl-instance.h"
+
 BABL_DEFINE_CLASS (babl_format)
 
 #endif
index 4de9d8942499e6107d48d8a47d3a1c2aa44c5617..c0fc31377847f56b0984ea4b8e13cb45f4d2d53c 100644 (file)
@@ -35,6 +35,7 @@ enum {
   BABL_U16_CIE_AB,
   BABL_U8_CIE_L,
   BABL_U8_CIE_AB,
+  BABL_TYPE_LAST_INTERNAL,
 
   BABL_MODEL_BASE = 1000,
   BABL_RGB,
@@ -51,9 +52,7 @@ enum {
   BABL_YCBCR_ALPHA,
   BABL_CIE_LAB,
   BABL_CIE_LAB_ALPHA,
-  BABL_CMY,
-  BABL_CMYK,
-  BABL_CMYK_ALPHA,
+  BABL_MODEL_LAST_INTERNAL,
 
   BABL_COMPONENT_BASE = 10000,
   BABL_RED,
@@ -77,13 +76,8 @@ enum {
   BABL_CIE_B,
   BABL_CB,
   BABL_CR,
-  BABL_CYAN,
-  BABL_MAGENTA,
-  BABL_YELLOW,
-  BABL_KEY,
-  BABL_Z_BUFFER,
   BABL_PADDING,
-
+  BABL_COMPONENT_LAST_INTERNAL,
 
   BABL_FORMAT_BASE = 100000,
   BABL_SRGB,
@@ -102,6 +96,7 @@ enum {
   BABL_YCBCR411,
   BABL_YCBCR422,
   BABL_YCBCR420,
+  BABL_FORMAT_LAST_INTERNAL,
 
   BABL_PIXEL_USER_BASE,
 };
index 479ac68aed1dc6cdace06c9e3e4dbcaa5b0b1f4a..749d58f632bec4bce94e464c86d3eaa5c90a486a 100644 (file)
@@ -17,7 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "babl-classes.h"
+#include "babl-internal.h"
 
 static const char *class_names[] =
   {
@@ -38,6 +38,7 @@ static const char *class_names[] =
     "BablFish",
     "BablFishReference",
     "BablImage",
+    "BablExtenstion",
     "BablSky"
   };
 
@@ -53,3 +54,13 @@ babl_class_name (BablClassType klass)
  */
 int babl_hmpf_on_name_lookups = 0;
 
+void
+babl_internal_init (void)
+{
+}
+
+void
+babl_internal_destroy (void)
+{
+}
+
index 8879c82887cc5a82acd9ed27aba24e182f6eb9f1..3b6225fba22d47f8c435f84b833c318a59bbaa47 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
+#include "babl-classes.h"
+#include "babl-instance.h"
+
 #include "babl-ids.h"
 #include "babl-util.h"
 #include "babl-memory.h"
+#include "babl-introspect.h"
+
 #include "babl-classes.h"
 
 /* internal classes */
 #include "babl-conversion.h"
+#include "babl-extension.h"
 /* */
 
-#define babl_log(args...) do {      \
-  fprintf (stdout, "%s:%i %s() ", \
-      __FILE__, __LINE__, __FUNCTION__); \
-  fprintf (stdout, args);           \
-  fprintf (stdout, "\n");                \
-} while (0)
+/**** LOGGER ****/
+#include <stdarg.h>
+
+static inline void
+real_babl_log (const char *file,
+               int         line,
+               const char *function,
+               const char *fmt, ...)
+{
+  Babl *extender = babl_extender();
+  va_list  varg;
+  
+
+  if (extender != babl_extension_quiet_log())
+    {
+      if (babl_extender())
+        fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+
+      fprintf (stdout, "%s:%i %s()\n\t", file, line, function);
+    }
+
+  va_start (varg, fmt);
+  vfprintf (stdout, fmt, varg);
+  va_end (varg);
+
+  fprintf (stdout, "\n");
+}
+
+#define babl_log(args...)  real_babl_log(__FILE__, __LINE__, __FUNCTION__, args)
+
+/********************/
+
+#define BABL_CLASS_TYPE_IS_VALID(klass_type) \
+    (  ((klass_type)>=BABL_INSTANCE ) && ((klass_type)<=BABL_SKY) ?1:0 )
+
+#define BABL_IS_BABL(obj)                              \
+(NULL==(obj)?0:                                        \
+ BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type)  \
+)
+
+extern int   babl_hmpf_on_name_lookups;
+
+const char  *babl_class_name     (BablClassType klass);
+void         babl_internal_init    (void);
+void         babl_internal_destroy (void);
 
 extern int babl_hmpf_on_name_lookups;
 
index a933b28b7496f118402221b8513d4118f8ed9fae..fb3ed80dadf44d76a25846fecc83aed326b5becc 100644 (file)
 #include "babl.h"
 #include "babl-internal.h"    /* for babl_log */
 
+#define BABL_LOG
+
 #ifdef BABL_LOG
 
 static void sampling_introspect     (Babl *babl);
 static void model_introspect        (Babl *babl);
 static void type_introspect         (Babl *babl);
 static void format_introspect       (Babl *babl);
+
 static int  each_introspect         (Babl *babl,
                                      void *user_data);
 #endif
 
+extern Babl *babl_extension_current_extender;
 void
-babl_introspect (void)
+babl_introspect (Babl *babl)
 {
 #ifdef BABL_LOG
-  babl_log ("Introspection report%s","");  
-  babl_log ("====================================================%s" ,"");  
+  Babl *extender_backup = babl_extension_current_extender;
+  
+  babl_extension_current_extender = babl_extension_quiet_log();
+
+  if (babl)
+    {
+      each_introspect (babl, NULL);
+      return;
+    }
+  babl_log ("Introspection report");  
+  babl_log ("====================================================");  
 
-  babl_log ("%s","");
-  babl_log ("Data Types:%s", "");
+  babl_log ("");
+  babl_log ("Data Types:");
   babl_type_each         (each_introspect, NULL);
-  babl_log ("%s","");
-  babl_log ("Sampling (chroma subsampling) factors:%s", "");
+  babl_log ("");
+  babl_log ("Sampling (chroma subsampling) factors:");
   babl_sampling_each     (each_introspect, NULL);
-  babl_log ("%s","");
-  babl_log ("Components:%s", "");
+  babl_log ("");
+  babl_log ("Components:");
   babl_component_each    (each_introspect, NULL);
-  babl_log ("%s","");
-  babl_log ("Models (of components):%s", "");
+  babl_log ("");
+  babl_log ("Models (of components):");
   babl_model_each        (each_introspect, NULL);
-  babl_log ("%s","");
-  babl_log ("Pixel formats:%s", "");
+  babl_log ("");
+  babl_log ("Pixel formats:");
   babl_format_each (each_introspect, NULL);
-  babl_log ("%s","");
-  babl_log ("conversions:%s", "");
+  babl_log ("");
+  babl_log ("conversions:");
   babl_conversion_each   (each_introspect, NULL);
-  babl_log ("%s","");
-  babl_log ("fishes:%s", "");
+  babl_log ("");
+  babl_log ("extensions:");
+  babl_extension_each    (each_introspect, NULL);
+  babl_log ("");
+  babl_log ("fishes");
   babl_fish_each         (each_introspect, NULL);
+  babl_log ("");
 
-  babl_log ("%s", "");
+  babl_extension_current_extender = extender_backup;
 #endif
 }
 
index 5dc0e430b7b5f50f16716f489cad2335e69d1753..e9f580cd1f8f6947aa2284bd80ba689103ce253b 100644 (file)
@@ -20,7 +20,9 @@
 #ifndef _BABL_INTROSPECT_H
 #define _BABL_INTROSPECT_H
 
+#include "babl-classes.h"
+
 void
-babl_introspect (void);
+babl_introspect (Babl *babl);
 
 #endif
index ff2026f791f4c2e35a080f8b69c5a83319c890ea..3f2b5d4f612e87490e189ff166cece7d026798ab 100644 (file)
@@ -153,10 +153,9 @@ babl_memory_sanity (void)
 {
   if (frees != mallocs + strdups + callocs)
     {
-      fprintf (stderr,
-"babl_memory usage does not add up!!!!!!!!\n"
+      babl_log ("memory usage does not add up!\n"
 "%s\n"
-"balance: %i-%i=%i\n",
+"\tbalance: %i-%i=%i\n",
   mem_stats(), (strdups+mallocs+callocs),frees, (strdups+mallocs+callocs)-frees);
     }
 }
index 12df09bd9d56f441a9e73ec37e6576f0e068ac5f..3a19b028e9e8e26dbd30f79dc638df4d83e6c6c1 100644 (file)
@@ -21,6 +21,8 @@
 #define _BABL_format_H
 
 #include "babl-classes.h"
+#include "babl-instance.h"
+
 BABL_DEFINE_CLASS (babl_model)
 
 #endif
index 2a5f879db639a3dc4a5d63df3ba4852a35a69d97..ed3329cbf7c55ec6ebe43cf25ac3e02baf8ad99a 100644 (file)
@@ -21,6 +21,8 @@
 #define _BABL_FORMAT_H
 
 #include "babl-classes.h"
+#include "babl-instance.h"
+
 BABL_DEFINE_CLASS (babl_format)
 
 #endif
index 6bc917ba8b4fb273d0e349607f13e9615b76014d..cdedccc8c4c1ad2785994e7b1847677f90abf6f9 100644 (file)
 #define _BABL_SAMPLING_H
 
 #include "babl-classes.h"
+#include "babl-instance.h"
 
-BABL_DEFINE_CLASS_NO_NEW_NO_ID(babl_sampling)
 Babl * babl_sampling (int horizontal,
                       int vertical);
+
+BABL_DEFINE_CLASS_NO_NEW_NO_ID(babl_sampling)
 #endif
index 88d9aa24ed919148d89ee63522de42b80d93dd75..d68b84818fefbfa04f58fbfe0c4e234d161812b8 100644 (file)
@@ -152,7 +152,9 @@ static int
 id_sanity (Babl *babl,
            void *user_data)
 {
-  if (0 == babl->instance.id)
+  if (0 == babl->instance.id &&
+      babl->instance.creator &&
+      !strcmp(BABL(babl->instance.creator)->instance.name, "BablBase"))
     {
       OK=0;
       babl_log ("%s\t'%s' has id==0",
index c0a83f9ca42d67665e8498d686f9418840c550e2..d6573266893e089bd7fc0e4ce486a6f6643a300f 100644 (file)
@@ -19,9 +19,9 @@
 
 #include "babl.h"
 #include "babl-internal.h"
-#include "babl-base.h"
 #include "babl-sanity.h"
 #include "babl-introspect.h"
+#include "babl-core.h"
 
 static int ref_count=0;
 
@@ -36,7 +36,11 @@ babl_init (void)
       babl_model_init ();
       babl_format_init ();
       babl_conversion_init ();
-      babl_base_init ();
+      babl_core_init ();
+      babl_sanity ();
+      babl_extension_base ();
+      babl_sanity ();
+      babl_extension_init ();
       babl_sanity ();
     }
 }
@@ -44,10 +48,9 @@ babl_init (void)
 void
 babl_destroy (void)
 {
-  /* babl_base is destroyed by the containing types */
-
   if (!--ref_count)
     {
+      babl_extension_destroy ();
       babl_fish_destroy ();
       babl_conversion_destroy ();
       babl_format_destroy ();
index 900f3edeff4999c2174ed8bbe6de51ea2d6af569..e47eb9142a70c9f2cc21bf9e14da7791a186ccf8 100644 (file)
@@ -37,9 +37,7 @@
 #include "babl-sampling.h"
 #include "babl-pixel-format.h"
 
-
 void babl_init       (void);
-void babl_introspect (void);
 void babl_destroy    (void);
 
 #endif
index c1b1d798c59d726a54bf84a9074e7df82cc67cb7..acfef1807a8e7d4ab013e6733ac6617fad68afdd 100644 (file)
@@ -5,7 +5,6 @@ h_sources =                     \
 c_sources =                    \
        babl-base.c             \
        cpercep.c               \
-       type-double.c           \
        type-float.c            \
        type-u8.c               \
        type-u16.c              \
index 010bbb130206776c22efa5064ef9193c2941b5e5..ee4ac513cb2fb552a18951a8fa35633d200aaab0 100644 (file)
@@ -43,7 +43,6 @@ babl_base_destroy (void)
  * types
  */
 
-void babl_base_type_double (void);
 void babl_base_type_float  (void);
 void babl_base_type_u8     (void);
 void babl_base_type_u16    (void);
@@ -51,8 +50,6 @@ void babl_base_type_u16    (void);
 static void
 types (void)
 {
-  babl_base_type_double ();  /* must be registered first since it is the
-                                reference */
   babl_base_type_float  ();
   babl_base_type_u8     ();
   babl_base_type_u16    ();
@@ -70,8 +67,7 @@ void babl_base_model_lab   (void);
 static void
 models (void)
 {
-  babl_base_model_rgb   (); /* must be registered first since it is the
-                               reference, (and contains the alpha definition) */
+  babl_base_model_rgb   ();
   babl_base_model_gray  ();
   babl_base_model_lab   ();
   babl_base_model_ycbcr ();
index 23853d44a3f0125b06e0e49a4a323de1dbb441ad..e76461f65af155c858b05b44f2fc4b659b304519 100644 (file)
@@ -38,26 +38,6 @@ babl_base_model_rgb (void)
 static void
 components (void)
 {
-  babl_component_new (
-    "R",
-    "id", BABL_RED,
-    "luma",
-    "chroma",
-    NULL);
-
-  babl_component_new (
-   "G",
-    "id",   BABL_GREEN,
-   "luma", 
-   "chroma",
-   NULL);
-  
-  babl_component_new (
-   "B",
-    "id",   BABL_BLUE,
-   "luma",
-   "chroma",
-   NULL);
 
   babl_component_new (
     "R'",
@@ -81,12 +61,6 @@ components (void)
    NULL);
 
 
-  babl_component_new (
-   "A",
-   "id",    BABL_ALPHA,
-   "alpha",
-   NULL);
-
   babl_component_new (
     "R*A",
     "id",    BABL_RED_MUL_ALPHA,
@@ -114,14 +88,6 @@ components (void)
 static void
 models (void)
 {
-  babl_model_new (
-    "rgba",
-    "id", BABL_RGBA,
-    babl_component_id (BABL_RED),
-    babl_component_id (BABL_GREEN),
-    babl_component_id (BABL_BLUE),
-    babl_component_id (BABL_ALPHA),
-    NULL);
 
   babl_model_new (
     "rgb",
@@ -300,9 +266,6 @@ premultiplied_to_non_premultiplied (int    src_bands,
     }
 }
 
-
-
-
 static void
 conversions (void)
 {
diff --git a/babl/base/type-double.c b/babl/base/type-double.c
deleted file mode 100644 (file)
index 7492658..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-#include <assert.h>
-
-#include "babl.h"
-
-static void
-convert_double_double (void *src,
-                       void *dst,
-                       int   src_pitch,
-                       int   dst_pitch,
-                       int   n)
-{
-  if (src_pitch == 64 &&
-      dst_pitch == 64)
-    {
-      memcpy (dst, src, n/8);
-      return;
-    }
-  while (n--)
-    {
-      (*(double *) dst) = (*(double *) src);
-      dst += dst_pitch;
-      src += src_pitch;
-    }
-}
-
-void
-babl_base_type_double (void)
-{
-  babl_type_new (
-    "double",
-    "id",          BABL_DOUBLE,
-    "bits",        64,
-    NULL);
-
-  babl_conversion_new (
-    "babl-base: double to double",
-    "source",      babl_type_id (BABL_DOUBLE),
-    "destination", babl_type_id (BABL_DOUBLE),
-    "linear", convert_double_double,
-    NULL
-  );
-}
index ff8739debb55965edfdeb6a89e1b5e03c3c0359a..ef27502e7d46b9040d5b035b7a4cc3730bceb019 100644 (file)
         
         <h3>Core</h3>
         <ul>
+          <li>Speed up name resolution in babl-db.h (using a hash table, and
+              probably also a id table)</li>
           <li>Meta level optimizations.</li>
           <li>Compile and/or runtime profiling. <em>(The speed of conversions
             is bound to 'wobble', according to architecture, compiler flags,
           calculation should be 3.13159, but the result obtained was 3.14x10^0,
           the relative error is 0.00159/3.14159 => 0.0005 (source: 'A new book
           on c (cook1_0a.pdf)')</li>-->
+<!--
+cvs:
+
+cp babl/babl-pixel-format.c babl/babl-format.c
+cp babl/babl-pixel-format.h babl/babl-format.h
+cp babl/babl-classes.c      babl/babl-internal.c
+cp babl/base/model-cmyk.c   extenstions/cmyk.c
+
+
+-->
         </ul>
 
         <a name='TODO-Extensions'></a>
index 6a03c1c0b4d4455d8ea5a4dbfcd617f262a66069..f801c0b30360c35a11d93126f92a9a4311c5a124 100644 (file)
@@ -23,8 +23,7 @@ sanity_SOURCES              = sanity.c
 
 
 AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
-LDADD = $(top_builddir)/babl/libbabl.la -lm
-
+LDADD = $(top_builddir)/babl/libbabl.la -lm -ldl
 
 noinst_PROGRAMS =      \
        introspect      \
index 6712c21dc9bc1e0d374b1204b378ffc205389638..84ff384e9b85adee755d7fcd47cb55e1cc47a627 100644 (file)
@@ -25,7 +25,7 @@ main (int    argc,
       char **argv)
 {
   babl_init ();
-  babl_introspect ();
+  babl_introspect (NULL);
   babl_destroy ();
   return 0;
 }